home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / ENV Server / README < prev   
Encoding:
Text File  |  1994-05-06  |  2.9 KB  |  74 lines  |  [TEXT/ALFA]

  1. EnvironServer - Environment Variables for the Macintosh
  2. Brent Burton - brentb@math.tamu.edu  5/31/93
  3. ----------------------------------------
  4. Environment Variables for the Macintosh
  5.  
  6. EnvServer.cpt.bin (or this directory) contains the full source and
  7. precompiled executables that implement UNIX-style environment variables
  8. on the Macintosh.
  9.  
  10. Under UNIX, each process inherits a set of environment variables from
  11. the shell which the program can manipulate through the getenv() and
  12. putenv() routines.  Since the Macintosh does not have any facility
  13. like this (well, Gestalt() is a small step in that direction) I decided to
  14. implement this feature.  The idea I came up with was to have a
  15. server run, handling requests from the processes.  The server is a
  16. background-only app called the "EnvironServer".
  17.  
  18. [Keep in mind that inter-program communication or user-definable options
  19. using environment variables is such a foreign concept on the Mac that
  20. this is one hell of a hack.  This barely works...  I did it to see if
  21. I could implement something like this.]
  22.  
  23.  
  24. About this version
  25.  
  26. This particular version is minimal but it works.  I plan to later change
  27. the server from a background-only app to having a nice interface for
  28. editing environment variables.  Right now, the server reads the file
  29. named "Environment" for initial environment variables and then handles
  30. put/get-env() calls from there.
  31.  
  32.  
  33. Using this code in your projects
  34.  
  35. If you are porting code that uses environment variables you will need
  36. to do a couple of things:
  37. * Add the line   #include "GetPutEnv.h"
  38.   to each source file that uses getenv() or putenv().
  39. * Add the library GPenv.lib to your program's project.
  40.   (a version is already compiled and included herein)
  41. * In the Unix world, a call to getenv() returns a pointer to static data.
  42.   In this implementation, getenv() returns a Macintosh Ptr type that
  43.   points to a NewPtr()-allocated chunk of memory.  If you want to be
  44.   careful, be sure to call DisposPtr() on the result when you're done.
  45.   See the example client's source code for more details.
  46.  
  47.  
  48. Using the demo
  49.  
  50. To see a quick demo, first double-click on the EnvironServer application.
  51. The server will start and then immediately become invisible (it goes to
  52. the background).  Next, start the "Client" application which is a small
  53. application that access 5 different environment variables and changes
  54. their values.  When the client is done, run it again - it will produce
  55. different results...
  56.  
  57. The server stays running throughout all this, so when you are done you
  58. may use the include "Application Killer" (AppKiller) program to kill the
  59. server process.  (Source is included for AppKiller for the curious types.)
  60.  
  61. ---------
  62. This code was originally created under Think C 5 and I have recompiled
  63. everything without problems under Symantec C 6. Anyway, this code is
  64. freely distributable and modifiable.  If you use it, I'd appreciate a
  65. brief mention.
  66.  
  67. Enjoy!
  68. -Brent
  69.  
  70. Brent Burton
  71. brentb@math.tamu.edu
  72.  
  73.  
  74.